<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        function getPrime(num1) {
            //判断一个数是否是素数  如果为素数返回1，不为素数返回0
            var ret = 1;
            if (num1 !== 1 && num1 % 2 !== 0) {
                for (var i = 3; i <= Math.sqrt(num1); i += 2) { //Math.sqrt(value)在js函数中表示给value值求平方根
                    if (num1 % i == 0) {
                        ret = 0;
                        break;
                    }

                }

            }
            return ret;
        }

        console.log(getPrime(9));
    </script>
</head>

<body>

</body>

</html>